local fenyin = fk.CreateSkill {
  name = "hanqing__fenyin",
}

Fk:loadTranslationTable{
  ["hanqing__fenyin"] = "奋音",
  [":hanqing__fenyin"] = "你的回合内，当你使用和上一张牌颜色不同的牌时，你可以摸一张牌。",

  ["@hanqing__fenyin-turn"] = "奋音",
}

fenyin:addEffect(fk.CardUsing, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(fenyin.name) and (data.extra_data or {}).hanqing__fenyin
  end,
  on_use = function(self, event, target, player, data)
    player:drawCards(1, fenyin.name)
  end,
})

fenyin:addEffect(fk.CardUsing, {
  can_refresh = function(self, event, target, player, data)
    return target == player and player:hasSkill(fenyin.name, true) and
      data.card.color ~= Card.NoColor and player.room.current == player
  end,
  on_refresh = function(self, event, target, player, data)
    local room = player.room
    local mark = player:getMark("@hanqing__fenyin-turn")
    if mark ~= 0 and mark ~= data.card:getColorString() then
      data.extra_data = data.extra_data or {}
      data.extra_data.hanqing__fenyin = true
    end
    room:setPlayerMark(player, "@hanqing__fenyin-turn", data.card:getColorString())
  end,
})

return fenyin
